﻿package net.wangit.dev;

import net.wangit.LabelUtil;
import net.wangit.MapList;
import net.wangit.context.ActionContext;
import net.wangit.context.ActionResult;
import net.wangit.util.Checker;

public class ObjectChecker {

	public ObjectChecker() {
	}

	public static final boolean invalid(ActionContext ac, MapList list,
			String lockName) {
		if (Checker.isEmpty(list)) {
			ActionResult result = ac.getActionResult();
			result.addError(LabelUtil.get(ac, "dev", "object_not_found"));
			result.setSuccessful(false);
			return true;
		}
		if ("1".equals(list.getRow(0).get(lockName))) {
			ActionResult result = ac.getActionResult();
			result.addError(LabelUtil.get(ac, "dev", "object_locked"));
			result.setSuccessful(false);
			return true;
		} else {
			return false;
		}
	}
}
